package com.zmn.plat.services.impl.online.service.group.city;

import com.zmn.plat.model.entity.online.service.group.city.OnlineServiceGroupCity;
import com.zmn.plat.model.entity.online.service.group.city.OnlineServiceGroupCityQuery;
import com.zmn.plat.persistence.interfaces.online.service.group.city.OnlineServiceGroupCityDao;
import com.zmn.plat.services.interfaces.online.service.group.city.OnlineServiceGroupCityService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import javax.annotation.Resource;
import java.util.List;



@Service
@Slf4j
public class OnlineServiceGroupCityServiceImpl implements OnlineServiceGroupCityService {

    @Resource
    OnlineServiceGroupCityDao onlineServiceGroupCityDao;

    @Override
    public OnlineServiceGroupCity findByKey(Integer relateId) {
        return onlineServiceGroupCityDao.findByKey(relateId);
    }

    @Override
    public List<OnlineServiceGroupCity> listPageByQuery(OnlineServiceGroupCityQuery query) {
        int count = countByQuery(query);
        query.setTotalCount(count);
        return onlineServiceGroupCityDao.listPageByQuery(query);
    }

    @Override
    public List<OnlineServiceGroupCity> listByQuery(OnlineServiceGroupCityQuery query) {
        return onlineServiceGroupCityDao.listByQuery(query);
    }

    @Override
    public List<OnlineServiceGroupCity> listAll() {
        return onlineServiceGroupCityDao.listAll();
    }

    @Override
    public Integer countByQuery(OnlineServiceGroupCityQuery query) {
        return onlineServiceGroupCityDao.countByQuery(query);
    }
    @Override
    public Integer updateByKey(OnlineServiceGroupCity onlineServiceGroupCity) {
        return onlineServiceGroupCityDao.updateByKey(onlineServiceGroupCity);
    }

    @Override
    public Integer insert(OnlineServiceGroupCity onlineServiceGroupCity) {
        return onlineServiceGroupCityDao.insert(onlineServiceGroupCity);
    }

    @Override
    public Integer insertBatch(List<OnlineServiceGroupCity> list) {
        if (CollectionUtils.isEmpty(list)) {
            log.error("在线客服分组城市配置新增数据,list为null");
            return null;
        }

        return onlineServiceGroupCityDao.insertBatch(list);
    }

    @Override
    public Integer deleteByGroupId(Integer groupId) {
        return onlineServiceGroupCityDao.deleteByGroupId(groupId);
    }

    @Override
    public Integer deleteByKey(Integer relateId) {
        return onlineServiceGroupCityDao.deleteByKey(relateId);
    }

}